package com.wangxi.boot9reg.mapper;

import com.wangxi.boot9reg.entity.Product;
import com.wangxi.boot9reg.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    @Select("select * from user where username=#{username}")
    User selectByName(String username);

    @Insert("insert into user values(null,#{username},#{password},#{nick})")
    void insert(User user);

    @Insert("insert into product values(null,#{title},#{price},#{saleCount})")
    void insertPro(Product product);

    @Delete("delete from product where id=#{id}")
    void delete(int id);

    @Select("select * from product")
    @Result(column = "sale_count",property = "saleCount")
    List<Product> select();

    @Select("select * from product where id=#{id}")
    @Result(column = "sale_count",property = "saleCount")
    Product selectPro(int id);

    @Update("update product set title=#{title},price=#{price},sale_count=#{saleCount} where id=#{id}")
    void updatePro(Product product);
}
